package com.greateamd.timetableasy.client.widgets.event;

import java.util.List;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiConstructor;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.greateamd.timetableasy.client.services.room.RoomService;
import com.greateamd.timetableasy.client.services.room.RoomServiceAsync;
import com.greateamd.timetableasy.client.services.util.ServerCall;
import com.greateamd.timetableasy.domain.Room;

public final class EventCampusManagerRoomListBox extends EventRoomListBox {

	
	public @UiConstructor EventCampusManagerRoomListBox(boolean autoLoad) {
		super(false);
		if(autoLoad){
			loadRooms();
		}
	}

	@Override
	public void loadRooms() {
		final RoomServiceAsync roomService = GWT.create(RoomService.class);
		new ServerCall<List<Room>>() {

			@Override
			protected void callService(AsyncCallback<List<Room>> asyncCallback) {
				roomService.getAllOfLoggedUser(asyncCallback);
			}

			@Override
			public void onSuccess(List<Room> result) {
				setRooms(result);
				showListRoom();
			}
		}.call();
	}
}
